package cn.edu.scnu.entry.service;

import cn.edu.scnu.entry.dao.RegisterMapper;
import cn.edu.scnu.entry.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RegisterServiceImpl implements RegisterService {
    @Autowired
    private RegisterMapper registerMapper;
    @Override
    public User register(User user) {
        //用户名已存在
        if(registerMapper.findByUsername(user.getUsername())!=null)
            return null;
        registerMapper.register(user);
        User userinfo=registerMapper.findByUsername(user.getUsername());
        return userinfo;
    }

    @Override
    public User login(User user) {
        User userinfo=registerMapper.login(user);
        if(userinfo!=null){
            return userinfo;
        }
        return null;
    }
}
